<template>
    <div class="list">
        <el-table :data="teacherList" stripe style="width: 100%">
            <el-table-column prop="id" label="ID" width="80" />
            <el-table-column prop="name" label="姓名" width="120" />
            <el-table-column label="性别" width="120">
                <template slot-scope="scope">{{ scope.row.gender ? '男' : '女' }}</template>
            </el-table-column>
            <el-table-column prop="station_name" label="职务" width="120" />
            <el-table-column prop="jobnum" label="职工号" width="160" />
            <el-table-column prop="account" label="联系方式" width="160"  />
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="delTeacher({id: scope.row.id,page,pagesize})">注销</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="page">
            <el-pagination background layout="prev, pager, next" :total="teacherTotal" :page-size="pagesize" @current-change="cheangePage"/>
        </div>
    </div>
</template>

<script>
    import { mapState,mapActions } from 'vuex';
    export default {
        name: 'WebTeacherList',
        data() {
            return {
                page: 0,
                pagesize: 15
            };
        },
        computed: {
            ...mapState('Teacher',['teacherList','teacherTotal'])
        },
        methods: {
            ...mapActions('Teacher',['getTeacherList','delTeacher']),
            cheangePage(page){
                let { pagesize } = this;
                this.page = --page;
                this.getTeacherList({page,pagesize});
            }
        },
        mounted(){
            let { page,pagesize } = this;
            this.getTeacherList({page,pagesize});
        }
    };
</script>

<style lang="less" scoped>
    @import "asle/index.less";
    .list {
        .w(880px);
        .page {
            .pos_f();
            .pos_rb(20px,20px);
        }
    }
</style>